export default {
    data() {
        return {
            tableData: [],
            count: 0,
            page: 1,      //分页数
            limit: 10,		//条数
        }
    },
    //进入页面加载
    mounted: function () {
        var that = this;
        //在缓存中获取值
        that.user_name = sessionStorage.getItem("user_name");
        that.user_id = sessionStorage.getItem("user_id");
        that.token = sessionStorage.getItem("access-token");
        if ((!that.token) || (!that.user_id) || (!that.user_name)) {
            that.$router.push('/login');
        }
        that.getList();
    },

    //方法
    methods: {
        /**
         * 获取列表
         */
        getList() {
            let that = this;
            that.tableData = [];
            //请求的数据
            let formData = {};
            formData.token = that.token;

            //请求邀请者列表
            that.$http.post(that.adminApi.api_url + "/api/ordereval/index", formData, {
                emulateJSON: true
            }).then(
                function (res) {
                    // 处理成功的结果
                    if (res.body.list) {
                        for (let i in res.body.list) {
                            if(res.body.list[i].is_evaluate !== 3) {
                                if (res.body.list[i].is_displayed === 1) {
                                    var status_text = '展示';
                                } else {
                                    var status_text = '不展示';
                                }
                            }else {
                                var status_text = '';
                            }
                            if (res.body.list[i].is_evaluate === 1) {
                                var text = '已评价';
                            } else if(res.body.list[i].is_evaluate === 2){
                                var text = '无需评价';
                            }else{
                                var text = '待评价';
                            }
                            if (res.body.list[i].is_evaluate === 1) {
                                if (res.body.list[i].evaluate_star === 1) {
                                    var star_text = '不错';
                                } else if(res.body.list[i].evaluate_star === 2){
                                    var star_text = '一般';
                                }else{
                                    var star_text = '不太好';
                                }
                            }else {
                                var star_text = '';
                            }

                            that.tableData.push({
                                sort: Number(i) + 1,
                                order_id:res.body.list[i].order_id,
                                goods_id:res.body.list[i].goods_id,
                                users_id:res.body.list[i].user_id,
                                is_evaluate:res.body.list[i].is_evaluate,
                                num: "<div class='blue'>"+res.body.list[i].sn+"</div>",
                                place_time: res.body.list[i].create_time,
                                over_time: res.body.list[i].completion_time,
                                shop_id: "<div class='blue'>"+res.body.list[i].goods_sn+"</div>",
                                name: res.body.list[i].real_name,
                                user_id: "<div class='blue'>"+res.body.list[i].user_no+"</div>",
                                collect: res.body.list[i].total_pay,
                                evaluate: text,
                                result: star_text,
                                evaluate_time: res.body.list[i].evaluate_time,
                                state: status_text,
                            });
                        }
                        that.count = res.body.count;
                    }
                },
                function () {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ '处理异常' }`
                    });
                });
        },
        /**
         * 下一页
         * @param pageNum
         */
        handleCurrentChange: function(currentPage) {
            var that = this;
            that.page = currentPage;
        },


        /**
         * 跳转到用户详情
         */
        toUserDetail:function (e) {
            let that = this;
            that.$router.push({path: '/user/information', query: {member_id: e}});
        },

        /**
         * 跳转到订单详情
         */
        toOrderDetail: function(e) {
            let that = this;
            that.$router.push({
                path: '/order/order_detail',
                query: {order_id: e}
            });
        },

        /**
         * 跳转至评价详情
         */
        edit:function (e) {
            let that = this;
            that.$router.push({
                path: '/order/evaluate_detail',
                query: {id: e}
            });
        },

        /**
         * 跳转至详情
         */
        toGoodsDetail:function (e) {
            let that = this;
            that.$router.push({path: '/commodity/goods_detail', query: {goods_id: e}});
        }
    }
}